import Vue from 'vue'
const EventBus = new Vue()

// 定义事件类型
export const eventTypes = {
    SEARCH: 'SEARCH',
    INITAPP: 'initApp',
    HIDE_TABBAR: 'hideTabbar',
    SHOW_TABBAR: 'showTabbar',
};

// 事件总线
export const eventBus  = {
    on(name, fn) {
        EventBus.$on(name, fn)
    },
    emit(name, data) {
        EventBus.$emit(name, data)
    },
    offOne(name) {
        EventBus.$off(name)
    },
    offAll() {
        EventBus.$off()
    }
}
